import { Service } from "cl-admin";
import BaseService from "@/service/base";
@Service("Erp")
class Erp extends BaseService {

    supplierList (params) {
        return this.$get("/supplierList", { params });
    }

    delSupplier (params) {
        return this.$post("/delSupplier", params);
    }

    productList (params) {
        return this.$get("/productList", { params });
    }

    delProduct (params) {
        return this.$post("/delProduct", params);
    }

    deptStock (params) {
        return this.$get("/deptStock", { params });
    }

    enterDetail ({ date, size, ...args }) {
        let params = {
			...args,
			size: size
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}

        return this.$get("/enterDetail", { params }).then(res => {
            return {
                list: res.list,
                pagination: {
                    ...params,
                    size,
                    total: res.total
                }
            }
        })
    }

    exitDetail ({ date, size, ...args }) {
        let params = {
			...args,
			size: size
		};
		if (date && date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}

        return this.$get("/exitDetail", { params }).then(res => {
            return {
                list: res.list,
                pagination: {
                    ...params,
                    size,
                    total: res.total
                }
            }
        })
    }

    deptReport ({ date, ...args}) {
        let params = {
			...args
		};
        if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		};

        return this.$get("/deptReport", { params });
    }
}
export default Erp;